/**
 * Created by admin on 2016/9/8.
 */

function setCookie(name, value, secs) {
    //secs 默认3600s
    var isecs;
    try {
        isecs = parseInt (secs);
    }
    catch (e) {
        isecs = 3600;
    }
    //设置名称为name,值为value的Cookie
    var expdate = new Date();   //初始化时间
    expdate.setTime(expdate.getTime() + isecs * 1000);   //时间
    document.cookie = name + "=" + encodeURI(value) + ";expires=" + expdate.toGMTString() + ";path=/";
}

function getCookie (c_name) {
    if (document.cookie.length > 0) {
        c_start = document.cookie.indexOf(c_name + "=")
        if (c_start != -1) {
            c_start = c_start + c_name.length + 1
            c_end = document.cookie.indexOf(";",c_start)
            if (c_end == -1) c_end = document.cookie.length
            return decodeURI(document.cookie.substring(c_start,c_end))
        }
    }
    return null;
}

function delCookie (c_name) {
    setCookie (c_name, "", -1);
}
